import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = 0;

        for (int i = 0; i < 5; i++) {
            int year = scanner.nextInt();
            int thousand = year / 1000;
            int hundred = (year % 1000) / 100;
            int ten = (year % 100) / 10;
            int one = year % 10;

            if (thousand == ten && one == (hundred + 1)) {
                count++;
            }
        }

        System.out.println(count);
        scanner.close();
    }
}

